package com.qf.common.exception;


import com.qf.common.utils.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(CustomerException.class)
    public R exceptionFeedback(CustomerException customException){
        customException.printStackTrace();
        return R.fail(customException.getCode(),customException.getMsg());
    }
    @ExceptionHandler(Exception.class)
    public R exceptionFeedback(Exception e){
        e.printStackTrace();
        return R.fail("未知错误");
    }
}
